#pymysql简单使用
import pymysql

try:


    conn = pymysql.connect(host='localhost',
                           user='zyh',
                           password='123456',
                           db='cov',
                           charset='utf8'
                           )
        #创建游标，默认元组
    cursor = conn.cursor()
    sql = 'select * from leiji'
    cursor.execute(sql)
    res = cursor.fetchall()
    print(res)
except:
     print('连接数据库失败！')
finally:

     cursor.close()
     conn.close()
     print('数据库关闭成功！')

